using SinBiota.Model.Entities;

namespace SinBiota.Model.Persistence.NHibernateMappings
{
    public class ProjectMapping : BaseEntityMapping<Project>
    {
        public ProjectMapping()
        {
            Map(p => p.Name).Not.Nullable().Length(256);
            HasManyToMany(p => p.Coordinators).Table("UserToProject_Coordinator").Inverse();
            HasManyToMany(p => p.Members).Table("UserToProject_Member").Inverse();
            Map(p => p.Objectives).Length(MAXCHAR);
            Map(p => p.TeamDescription).Length(MAXCHAR);
            Map(p => p.ParticipatingInstitutions).Length(MAXCHAR);
            Map(p => p.ExpectedProducts).Length(MAXCHAR);
            Map(p => p.ProjectStatus).Length(20);
            Map(p => p.WebsiteURL).Length(128);
            Map(p => p.StartDate);
            Map(p => p.EndDate);
            Map(p => p.FAPESPProject);
            Map(p => p.Biome).Length(800);
            Map(p => p.Abstract).Length(MAXCHAR); 
            HasManyToMany(p => p.Keywords);
            HasMany(x => x.Occurrences).Inverse().Cascade.AllDeleteOrphan();
        }
    }
}
